package com.xuetang9.t9.hotel.services.impl;

import com.xuetang9.t9.hotel.beans.CommodityExpense;
import com.xuetang9.t9.hotel.mapper.ICommodityExpenseMapper;
import com.xuetang9.t9.hotel.services.ICommodityExpenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommodityExpenseServiceImpl implements ICommodityExpenseService {

    @Autowired
    private ICommodityExpenseMapper commodityExpenseMapper;

    @Override
    public boolean save(CommodityExpense commodityExpense) {
        if(null == commodityExpense){
            return false;
        }
        if(commodityExpense.getBillId() == null || commodityExpense.getArriveId() == null || commodityExpense.getAttribute() == null){
            return false;
        }
        return commodityExpenseMapper.insert(commodityExpense) > 0;
    }

    @Override
    public boolean alter(CommodityExpense commodityExpense) {
        if(null == commodityExpense){
            return false;
        }
        if(commodityExpense.getBillId() == null || commodityExpense.getArriveId() == null || commodityExpense.getAttribute() == null){
            return false;
        }
        return commodityExpenseMapper.update(commodityExpense) > 0;
    }

    @Override
    public boolean removeByBillId(Long id) {
        if(null == id){
            return false;
        }
        return commodityExpenseMapper.deleteByBillId(id) > 0;
    }

    @Override
    public boolean removeByCommId(Integer id) {
        if(null == id){
            return false;
        }
        return commodityExpenseMapper.deleteByArriveId(id) > 0;
    }
}
